﻿using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Salesforce.Common;

namespace WP_ForceDotCom_Pivot
{
    public class auth
    {

        public static void doauth()
        {
            Globals.sessionstatus = "disconnected - tap";
            var status = runauth();
        }
        public static async Task runauth()
        {
            var authentication = new AuthenticationClient();
            // TODO: 
            // You need a free Force.com developer environment: https://events.developerforce.com/signup
            // In your developer environment, go to Setup > Create > Apps, scroll to Connected Apps
            // Create a new conected app, enable OAuth settings at your comfort level, save
            // Grab the consumer key, consumer secret, your own Force.com environment username / pw, and put them below
            await authentication.UsernamePassword("YOUR-CONSUMER-KEY", "YOUR-CONSUMER-SECRET", "YOUR-USERNAME", "YOUR-PASSWORD");

            Globals.sessiontoken = authentication.AccessToken; // assign new token value
            Globals.sessionurl = authentication.InstanceUrl; // assign URL for the API
            Globals.sessionapiversion = authentication.ApiVersion; // assign API version

            Globals.sessionstatus = "connected"; // assign new status
        }
    }
}
